<template>
    <view class="content">
        <view class="area-box">
            <textarea maxlength="100" @input="textareaBInput"
                :placeholder="isAudit=='1'?'请输入审核通过意见(选填)':'请输入审核不通过意见(必填)'"></textarea>
        </view>
        <div class="common-btn">
            <button class="cu-btn block bg-green margin-tb-sm lg" @click="submit">保存</button>
        </div>
    </view>
</template>

<script>
    import api from '@/api/api.js';
    export default {
        data() {
            return {
                content: '',
                customerUserId: undefined,
                isAudit: null, // 审核方式：1、通过，2、拒绝
            }
        },
        onLoad(options) {
            this.customerUserId = options.customerUserId;
            this.isAudit = options.isAudit
            if (this.isAudit == '1') {
                uni.setNavigationBarTitle({
                    title: '通过审核'
                })
            } else if (this.isAudit == '2') {
                uni.setNavigationBarTitle({
                    title: '拒绝审核'
                })
            }
            // 修改顶部导航背景色
            uni.setNavigationBarColor({
                frontColor: '#ffffff',
                backgroundColor: '#39b54a',
                animation: {
                    duration: 400,
                    timingFunc: 'easeIn'
                }
            })
        },
        methods: {
            submit() {
                // var data = {
                //     customerUserId: this.customerUserId,
                //      isAudit: this.isAudit,
                //     remark: this.content
                // }
                // api.auditCustomer(data).then(
                var data = { customerId: this.customerUserId, approvalStatus: this.isAudit, remark: this.content }
                api.approval(data).then(
                    res => {
                        if (res.code == 200) {
                            uni.showToast({
                                title: '提交成功',
                                duration: 2000
                            });
                            setTimeout(function() {
                                uni.navigateBack({
                                    success: () => {}
                                })
                            }, 500);
                        } else {
                            uni.showToast({
                                title: res.msg,
                                icon: 'none',
                            });
                        }

                    },
                    rej => {}
                );
            },
            textareaBInput(e) {
                this.content = e.detail.value
            }
        }
    }
</script>

<style lang="scss">
    page {
        height: 100%;
    }

    .content {
        height: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;

        .area-box {
            margin-top: 20upx;
            padding: 20upx 24upx;
            background: #fff;

            textarea {
                width: 100%;
                height: 200upx;
                border: 1px solid #f7f7f7;
                border-radius: 8upx;
                padding: 20upx;
            }
        }

    }
</style>